<?php

use think\migration\Migrator;
use think\migration\db\Column;

class BasicFacility extends Migrator
{
    public function up()
    {
        $table = $this->table('basic_facility');
        $table
            //step1:基本信息
            ->addColumn('number', 'string', ['limit' => 50, 'default' => '', 'comment' => '设施编号'])
            ->addColumn('name', 'string', ['limit' => 50, 'default' => '', 'comment' => '设施名称'])
            ->addColumn('name_cn', 'string', ['limit' => 20, 'default' => '', 'comment' => '设施名称中文名称'])
            ->addColumn('description', 'string', ['limit' => 200, 'comment'=>'设施简介'])

            //step2：关联ID
            ->addColumn('boiler_id', 'integer', ['limit' => 11, 'default' => '0', 'comment' => '锅炉ID'])
            ->addColumn('machine_id', 'integer', ['limit' => 11, 'default' => '0', 'comment' => '机组ID'])
            ->addColumn('company_id', 'integer', ['limit' => 11, 'default' => '0', 'comment' => '公司ID'])
            ->addColumn('drain_id', 'integer', ['limit' => 11, 'default' => '0', 'comment' => '排口ID'])
            ->addColumn('type', 'integer', ['limit' => 1, 'signed' => true,'comment' => '工艺类型ID，1脱硝2脱硫'])

            ->addColumn('delete_time', 'integer', ['limit' => 11, 'default' => 0, 'comment'=>'软删除'])

            //注释
            ->setComment('基本信息 - 设施')

            //引擎
            ->setEngine('InnoDB')
            ->save();
    }

    public function down()
    {
        $this->table('basic_facility')->drop();
    }
}
